<template>
  <div class="bdsharebuttonbox">
    <a
      v-for="item in defaultConfig.shareList"
      :key="item.id"
      :class="'bds_' + item.name"
      :data-cmd="item.name"
    ></a>
  </div>
</template>

<script>
export default {
  data() {
    return {
      defaultConfig: {
        shareList: ["weixin"],
        common: {},
        share: [{ bdSize: 24 }],
        slide: false,
        image: false,
        selectShare: false
      },
      vshareConfig: {
        shareList: [
          { name: "weixin", title: "微信" }
          // 此处放分享列表（ID）
        ],
        common: {
          //此处放置通用设置
          bdText: "【好融艺】-被光抓走的人抽奖活动",
          bdUrl: "http://gift.hrycf.com",
          bdSign: "off"
        },
        share: [
          {
            //此处放置分享按钮设置
            bdSize: 32
          }
        ],
        slide: false,
        image: false,
        selectShare: false
      }
    };
  },
  beforeCreate() {
    window._bd_share_main = "";
  },
  mounted() {
    if (this.vshareConfig) {
      this.vshareConfig.shareList
        ? (this.defaultConfig.shareList = this.vshareConfig.shareList)
        : "";
      if (this.vshareConfig.common) {
        this.defaultConfig.common = this.vshareConfig.common;
      }
      if (this.vshareConfig.share) {
        this.defaultConfig.share = this.vshareConfig.share;
      }
      if (this.vshareConfig.slide) {
        this.defaultConfig.slide = this.vshareConfig.slide;
      }
      if (this.vshareConfig.image) {
        this.defaultConfig.image = this.vshareConfig.image;
      }
      if (this.vshareConfig.selectShare) {
        this.defaultConfig.selectShare = this.vshareConfig.selectShare;
      }
    }
    window._bd_share_config = this.defaultConfig;
    document
      .getElementsByTagName("body")[0]
      .appendChild(document.createElement("script")).src =
      "/static/api/js/share.js";
  }
};
</script>
<style scoped lang="less">
.bdsharebuttonbox {
  .flex_content ();
  a {
    margin-right: 30px;
  }
}
</style>
